# Copyright (C) 2018 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load("//tools/build:rules.bzl", "api_library", "apic_template")

filegroup(
    name = "api_files",
    srcs = glob([
        "*.api",
        "api/*.api",
    ]),
    visibility = ["//visibility:public"],
)

api_library(
    name = "api",
    api = "gles.api",
    apiname = "gles",
    includes = [":api_files"],
    visibility = ["//visibility:public"],
    deps = ["//gapis/messages:api"],
)

apic_template(
    name = "generated",
    api = ":api",
    templates = [
        "//gapis/api/templates:api",
        "//gapis/api/templates:api_types",
        "//gapis/api/templates:mutate",
        "//gapis/api/templates:constant_sets",
        "//gapis/api/templates:convert",
        "//gapis/api/templates:proto",
        "//gapis/api/templates:state_serialize",
    ],
    visibility = ["//visibility:public"],
)

go_library(
    name = "go_default_library",
    srcs = [
        "compat.go",
        "compat_buffers.go",
        "compat_client.go",
        "context.go",
        "custom_replay.go",
        "datatypes.go",
        "dependency_graph_behaviour_provider.go",
        "doc.go",
        "draw_call.go",
        "draw_call_mesh.go",
        "externs.go",
        "extras.go",
        "find_issues.go",
        "gles.go",
        "glsl.go",
        "graph_visualization.go",
        "guess_semantics.go",
        "helpers.go",
        "image.go",
        "importance.go",
        "issue_whitelist.go",
        "links.go",
        "markers.go",
        "math.go",
        "read_depth.go",
        "read_framebuffer.go",
        "read_texture.go",
        "replay.go",
        "resources.go",
        "state.go",
        "state_builder.go",
        "string.go",
        "stub_program.go",
        "texture_compat.go",
        "tweaker.go",
        "undefined_framebuffer.go",
        "version.go",
        "wireframe.go",
    ],
    embed = [
        ":generated",  # keep
        ":gles_go_proto",
    ],
    importpath = "github.com/google/gapid/gapis/api/gles",
    visibility = ["//visibility:public"],
    deps = [
        "//core/app/analytics:go_default_library",
        "//core/app/status:go_default_library",
        "//core/context/keys:go_default_library",
        "//core/data/binary:go_default_library",
        "//core/data/compare:go_default_library",
        "//core/data/dictionary:go_default_library",
        "//core/data/endian:go_default_library",
        "//core/data/id:go_default_library",
        "//core/data/protoconv:go_default_library",
        "//core/event/task:go_default_library",  # keep
        "//core/image:go_default_library",
        "//core/image/astc:go_default_library",
        "//core/log:go_default_library",
        "//core/math/interval:go_default_library",
        "//core/math/sint:go_default_library",
        "//core/math/u32:go_default_library",
        "//core/math/u64:go_default_library",
        "//core/memory/arena:go_default_library",  # keep
        "//core/os/device:go_default_library",
        "//core/stream:go_default_library",
        "//core/stream/fmts:go_default_library",
        "//core/text:go_default_library",
        "//gapil/constset:go_default_library",  # keep
        "//gapis/api:go_default_library",
        "//gapis/api/gles/gles_pb:go_default_library",
        "//gapis/api/transform:go_default_library",
        "//gapis/capture:go_default_library",
        "//gapis/config:go_default_library",
        "//gapis/database:go_default_library",
        "//gapis/memory:go_default_library",
        "//gapis/memory/memory_pb:go_default_library",  # keep
        "//gapis/messages:go_default_library",
        "//gapis/replay:go_default_library",
        "//gapis/replay/builder:go_default_library",
        "//gapis/replay/protocol:go_default_library",
        "//gapis/replay/value:go_default_library",
        "//gapis/resolve:go_default_library",
        "//gapis/resolve/dependencygraph:go_default_library",
        "//gapis/service:go_default_library",
        "//gapis/service/box:go_default_library",
        "//gapis/service/memory_box:go_default_library",  #keep
        "//gapis/service/path:go_default_library",
        "//gapis/service/types:go_default_library",  #keep
        "//gapis/shadertools:go_default_library",
        "//gapis/stringtable:go_default_library",
        "//gapis/vertex:go_default_library",
        "@com_github_golang_protobuf//proto:go_default_library",
        "@com_github_pkg_errors//:go_default_library",
    ],
)

proto_library(
    name = "gles_proto",
    srcs = ["resolvables.proto"],
    visibility = ["//visibility:public"],
    deps = [
        "//core/image:image_proto",
        "//gapis/service/path:path_proto",
    ],
)

go_proto_library(
    name = "gles_go_proto",
    importpath = "github.com/google/gapid/gapis/api/gles",
    proto = ":gles_proto",
    visibility = ["//visibility:public"],
    deps = [
        "//core/image:go_default_library",
        "//gapis/service/path:go_default_library",
    ],
)

go_test(
    name = "go_default_test",
    srcs = [
        "compat_test.go",
        "dead_code_elimination_test.go",
        "dependencygraph2_test.go",
        "markers_test.go",
        "stub_program_test.go",
    ],
    embed = [":go_default_library"],
    deps = [
        "//core/assert:go_default_library",
        "//core/log:go_default_library",
        "//core/memory/arena:go_default_library",
        "//core/os/device:go_default_library",
        "//core/os/device/bind:go_default_library",
        "//gapis/api:go_default_library",
        "//gapis/api/transform:go_default_library",
        "//gapis/capture:go_default_library",
        "//gapis/database:go_default_library",
        "//gapis/memory:go_default_library",
        "//gapis/resolve/dependencygraph:go_default_library",
        "//gapis/resolve/dependencygraph2:go_default_library",
    ],
)
